
<!-- src/views/Login.vue -->
<template>
  <div class="login-container">
    <div class="login-box">
      <div class="logo-container">
        <img src="/index.png" alt="Logo" class="logo" />
      </div>
      <h2>electron-sqlite3系统</h2>
      <el-form :model="loginForm" :rules="rules" ref="loginFormRef">
        <el-form-item prop="password">
          <el-input
              v-model="loginForm.password"
              type="password"
              placeholder="请输入解锁密码"
              show-password
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleLogin" style="width: 100%">
            解锁
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup>import { reactive, ref, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'

const loginFormRef = ref()
const router = useRouter()

const loginForm = reactive({
  password: ''
})

const rules = {
  // password: [
  //   { required: true, message: '请输入解锁密码', trigger: 'blur' }
  // ]
}

// 页面加载时隐藏滚动条
onMounted(() => {
  document.body.style.overflow = 'hidden'
})

// 页面卸载时恢复滚动条
onUnmounted(() => {
  document.body.style.overflow = 'auto'
})

const handleLogin = () => {
  if (loginForm.password === '123456') {
    ElMessage.success('登录成功')
    router.push('/resource-management')
  } else {
    ElMessage.error('密码错误')
  }
}
</script>

<style scoped>.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  background-color: #6B6CD0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  position: fixed;
  top: 0;
  left: 0;
}

.login-box {
  width: 400px;
  padding: 30px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  text-align: center;
}

.logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.logo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
}

.login-box h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
}

/* 响应式设计，确保在小屏幕上也能正常显示 */
@media (max-width: 480px) {
  .login-box {
    width: 90%;
    padding: 20px;
  }
}

@media (max-height: 500px) {
  .login-box {
    padding: 15px;
  }

  .logo {
    width: 50px;
    height: 50px;
  }

  .login-box h2 {
    margin-bottom: 20px;
    font-size: 20px;
  }
}
</style>